#import "OrderSectionCell.h"
#import "XMDetailModel.h"


@interface OrderSectionCell()
@property (nonatomic, strong) UILabel *currentCityLabel;
@property (nonatomic, strong) UIButton *rightButton;
@end


@implementation OrderSectionCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.backgroundColor = [UIColor whiteColor];
    
    // 创建标题
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 12, 100, 20)];
    titleLabel.text = @"见面时间";
    titleLabel.font = [UIFont systemFontOfSize:14.0];
    titleLabel.textColor = kColorHEX(0x666666);
    [self.contentView addSubview:titleLabel];
    self.currentCityLabel = titleLabel;
//    // 创建购买按钮
    UIButton *buyButton = [UIButton buttonWithType:UIButtonTypeSystem];
    buyButton.frame = CGRectMake(self.contentView.bounds.size.width - 180, 7, 180, 30);
    [buyButton setTitle:@"北京市朝阳区东三环新钟楼3楼·1.2km" forState:UIControlStateNormal];
    self.rightButton = buyButton;

    [buyButton setTitleColor:kColorHEX(0x333333) forState:UIControlStateNormal];
    buyButton.titleLabel.textAlignment = NSTextAlignmentLeft;
    [buyButton.titleLabel sizeToFit];
    buyButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [buyButton addTarget:self action:@selector(buyButtonTapped) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:buyButton];

    // 创建分割线
    UIView *separatorLine = [[UIView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.contentView.frame)+2, kScreenWidth-30, 0.5)];
    separatorLine.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
    [self.contentView addSubview:separatorLine];
}
-(void)setupData:(XMDetailModel *)data
{
    self.currentCityLabel.text = data.addrDetail;
    [self.rightButton setTitle:data.addrPoint forState:UIControlStateNormal];
 
}
- (void)buyButtonTapped {
    NSLog(@"立即购买按钮被点击");
    // 处理购买按钮点击事件
}

- (void)cartButtonTapped {
    NSLog(@"加入购物车按钮被点击");
    // 处理加入购物车按钮点击事件
}

@end    
